Copyright: Copyright © 1995 Fitco


AsciiFile
AsciiFile Property

Applies to

TAscii2DB component

Declaration

property AsciiFile: TFileName;

Description

AsciiFile specifies the name of the file to be used to import data to the destination table.


CvtDB Unit

The CvtDB unit contains the declarations for the TAscii2DB component.

When you add a component declared in this unit to a form, the unit is automatically added to the uses clause of that form's unit.

The following items are declared in the CvtDB unit:

Components

TAscii2DB


Delimiter
Delimiter Property

Applies to

TAscii2DB component

Declaration

property Delimiter: Char;

Description

Delimiter specifies the character within the ASCII file that is used to surround string fields.  Default is a double quote.


Destination
Destination Property

Applies to

TAscii2DB component

Declaration

property Destination: TTable;

Description

Destination specifies the name of an existing TTable component corresponding to a database table to be used to put the imported data.  This table is emptied before new records are added from the ASCII file.


ErrorCode
ErrorCode Property

Applies to

TAscii2DB component

Declaration

property ErrorCode: Integer;

Description

Run-time and read only. After the Execute method is processed, the value returned in ErrorCode indicated any errors that might have occurred during importing.  The GetErrorString method can be used to convert the result to an string.  This property should be check after each Execute.

0	No errors detected.

1	Can not get exclusive access to database.

2	Ascii file does not exist.[<file name>].

3	Can not open database.

4	Error in ascii file.

5	Ascii table does not match database.

6	Field count does not match database.

7	Data type mismatch in ascii file.

8	Field names do not match database.

97	Busy.

98	User aborted.

99	Destination table does not exist.


Events

 Key events

  	OnTick


Execute
Execute Method

Applies to

TAscii2DB component

Declaration

procedure Execute;

Description

Use the Execute method to start the import process.  The Destination table will be emptied and then filled with the data from the AsciiFile.  If an occurs while importing, an error code is return in the ErrorCode property. This should be checked after each use of Execute.  Use the GetErrorString Method to convert the error code to an error string.

Do not attempt to call the Execute Method while an Execute is in progress.  Doing so will abort the Execute and return a "Busy" ErrorCode.


FieldList
FieldList Property

Applies to

TAscii2DB component

Declaration

property FieldList: TStrings;

Description

Set the strings in the Fieldlist to match the field name of the destination database.  The order of the names should match that of the ASCII file.  To skip a field in the ASCII file, enter 'SKIP' for a field name.  Fields not listed will be left empty in the destination table.


GetErrorString
GetErrorString Method

Applies to

TAscii2DB component

Declaration

function GetErrorString(ErrorCode: integer): String;

Description

The GetErrorString Method returns a string containing a description of the error that occurred during an Execute method as returned in the ErrorCode property.


Methods

 Key methods

  	Execute

  	GetErrorString

  	StopExecute


OnTick
OnTick Event

Applies to

TAscii2DB component

Declaration

property OnTick: TNotifyEvent;

Description

The OnTick event occurs every time TickCount records have been imported.


ParsedCount
ParsedCount Property

Applies to

TAscii2DB component

Declaration

property ParsedCount: LongInt;

Description

Run-time and read only. After Execute, ParsedCount indicates the number of recorded imported.  ParsedCount can be read during the the import process in the OnTick event.


Properties

 Run-time only	 Key properties

  	AsciiFile	 	ParsedCount

  	Delimiter	  	RecordLimit

  	Destination	  	RemoveESC

 	ErrorCode	  	Separator

  	FieldList	  	ShowDlg

  	Name	Tag

Owner	  	TickCount


RecordLimit
RecordLimit Property

Applies to

TAscii2DB component

Declaration

property RecordLimit: LongInt;

Description

RecordLimit specifies the number of records to get from the AsciiFile.  If set to 0, all records will be retrieved.  Default is 0.


RemoveESC
RemoveESC Property

Applies to

TAscii2DB component

Declaration

property RemoveESC: boolean;

Description

Set the RemoveESC property to true if the ASCII file contains double quotes that are "escaped" with a backslash in front of them.  When RemoveESC is set to true, the backslashes will be removed.


Separator
Separator Property

Applies to

TAscii2DB component

Declaration

property Separator: Char;

Description

Separator specifies the character within the ASCII file that is used to separate fields.  Default is a comma.


ShowDlg
ShowDlg Property

Applies to

TAscii2DB component

Declaration

property ShowDlg: boolean;

Description

ShowDlg, if set to true, enables a small dialog in the center of your application that shows a progress bar and a cancel button.


StopExecute
StopExecute Method

Applies to

TAscii2DB component

Declaration

procedure StopExecute;

Description

Use the StopExecute Method to stop the import process after Execute has been started.  The ErrorCode  will be set to "user aborted"


TAscii2DB

TAscii2DB Component

Properties	Methods	Events

Unit

CvtDB

Description

Ascii2DB enables you to perform an importing of data from a delimited ASCII file to a table. Set the AsciiFile property to specify the name of the file to be used for input.  Set the Destination  property to specify a TTable component corresponding to a database table.  The destination table must already exist.  Set the strings in the FieldList property to the name of the field in the database.  The order should reflect the order in the ASCII file.  If there is a field in the ASCII file that you do not want to import, set the name to 'SKIP'.  Any field not listed will be left nil in the destination table.

Use the RecordLimit property to limit the number of records to be imported.  Use the Separator and Delimiter properties to change the default character that separate the data in the ASCII file.

Use the Execute method to start the import process.  The destination table will be emptied and then filled with the data in the ASCII file.  If an occurs while importing, an error code is return in the ErrorCode property. This should be checked after each use of Execute.  Use the GetErrorString Method to convert the error code to an error string.

If there are no errors, the ParsedCount property indicates the number of records imported.

In addition to these properties and methods, this component also has the properties and methods that apply to all components.

{revision 1.0}


TickCount
TickCount Property

Applies to

TAscii2DB component

Declaration

property TickCount: Integer;

Description

During an Execute, the OnTick event is called every time TickCount records are imported.  At the same time, the Applicaion.ProcessMessages Method is called.  The default is 100 records.  Setting TickCount to 0 prevents calling OnTick and the Application.ProcessMessages method.